﻿using Hotel.Model;

namespace Hotel.DAL
{
    public class AdminDAL
    {
        public AdminDAL(Mycount mycount)
        {
            Mycount = mycount;
        }
        public Mycount Mycount { get; }
        /// <summary>
        /// 管理员登陆
        /// </summary>
        /// <param name="useName">管理员账号</param>
        /// <param name="usePwd">管理员密码</param>
        /// <returns></returns>
        public dynamic Login(string useName,string usePwd)
        {
            try
            {
                //判断用户名是否存在
                var count = Mycount.Admins.Where(c => c.UserName == useName).Count();
                if (count==0)
                {
                    return -1;//表示用户名不存在
                }
                else
                {
                    var c=Mycount.Admins.Where(c => c.UserName == useName&&c.UserPwd==usePwd).Count();
                    if(c==0)
                    {
                        return -2;//表示密码错误
                    }
                    else
                    {
                        var info = Mycount.Admins.Where(c => c.UserName == useName && c.UserPwd == usePwd).FirstOrDefault();
                        return info;
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        
        public int Login1()
        {
            return 3;
        }
    }
}